package sky.treasure;

import sky.treasure.properties.AreaPropertyHolder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Gauss
 * Date: 17.01.14
 * Time: 21:19
 * To change this template use File | Settings | File Templates.
 */
public class AreaView extends Area implements Serializable {

    public AreaView(Coordinates measuresFrom, Coordinates measuresTo, AreaPropertyHolder areaPropertyHolder) {
        super(measuresFrom, measuresTo, areaPropertyHolder);
    }

    public AreaView(Coordinates measuresTo, AreaPropertyHolder areaPropertyHolder) {
        super(measuresTo, areaPropertyHolder);
    }

    public List getList() {
        ArrayList<ArrayList<Cell>> listArea = new ArrayList<ArrayList<Cell>>(getMeasuresTo().getX());
        for (int i=0; i<getMeasuresTo().getX(); i++) {
            ArrayList<Cell> listRow = new ArrayList<Cell>(getMeasuresTo().getY());
            for (int j=0; j<getMeasuresTo().getY(); j++) {
                Cell cell = new Cell(new Coordinates(i, j));
                areaPropertyHolder.fillCell(cell);
                listRow.add(cell);
            }
            listArea.add(listRow);
        }
        return listArea;
    }
}
